//
//  UseAgreementVC.m
//  CleanerAir_Project
//
//  Created by 付亚杰 on 16/6/3.
//  Copyright © 2016年 Beijing Colin El Internet. All rights reserved.
//

#import "UseAgreementVC.h"
#import "CARegisteredVC.h"

@interface UseAgreementVC ()

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *textViewH;

@end

@implementation UseAgreementVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    if ([self.joinUs isEqualToString:@"加入我们"]) {
        self.textViewH.constant = 55.0f;
        self.title = @"加入我们";
        [self initJoinUs];
    }
    // Do any additional setup after loading the view from its nib.
}


#pragma mark -- 初始化加入我们
- (void)initJoinUs{
    
    CGFloat viewH = 30;
    
    UIView *joinUsView = [[UIView alloc] initWithFrame:(CGRectMake(0, MAIN_HEIGHT - viewH - 15 - 64, MAIN_WIDTH, viewH))];
    
    UIButton *cancel = [UIButton buttonWithType:UIButtonTypeCustom];
    cancel.frame = CGRectMake(26, 1, 80, viewH - 2);
    [cancel setTitle:@"取消" forState:(UIControlStateNormal)];
    [cancel setTitleColor:[UIColor grayColor] forState:(UIControlStateNormal)];
    cancel.layer.borderWidth = 1.0f;
    cancel.layer.borderColor = [UIColor grayColor].CGColor;
    [cancel addTarget:self action:@selector(cancelClick) forControlEvents:(UIControlEventTouchUpInside)];
    
    
    UIButton *ok = [UIButton buttonWithType:UIButtonTypeCustom];
    ok.frame = CGRectMake(MAIN_WIDTH - 80 - 26, 1, 80, viewH - 2);
    [ok setTitle:@"接受" forState:(UIControlStateNormal)];
    [ok setTitleColor:[UIColor grayColor] forState:(UIControlStateNormal)];
    ok.layer.borderWidth = 1.0f;
    ok.layer.borderColor = [UIColor grayColor].CGColor;
    [ok addTarget:self action:@selector(okClick) forControlEvents:(UIControlEventTouchUpInside)];
    
    [joinUsView addSubview:cancel];
    [joinUsView addSubview:ok];
    
    [self.view addSubview:joinUsView];
    
}


#pragma mark -- 取消 按钮 和 接受按钮的  点击事件
- (void)cancelClick{
    
    
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)okClick{
    
    CARegisteredVC *registeredVC = [[CARegisteredVC alloc] init];
    
    self.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:registeredVC animated:YES];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
